<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
</html>
<script type="text/javascript">  
  
    localStorage.setItem("coffeeType", "mocha");  
    localStorage.setItem("coffeePrice", "28");  
    verify();   //验证本地存储  
  
    
    localStorage.removeItem("coffeeType");  // 删除一项
	verify();   //验证coffeeType是否存在
	
	
    localStorage.clear();  // 清空
    verify();   //验证coffeeType和coffeePrice是否存在  
  
    //自定义验证函数，验证coffeeType和coffeePrice的数据是否存在  
    function verify(){  
        var type = localStorage.getItem("coffeeType");  
        var price = localStorage.getItem("coffeePrice");  
        type = type ? type : '不存在';  
        price = price ? price : '不存在';  
  
        alert( "coffeeType: " + type + "\n\n" + "coffeePrice: " + price );  
    }  
</script>   